home *** CD-ROM | disk | FTP | other *** search
/ APDL Other Worlds / APDL Other Worlds Collection.iso / SF3000 / Extras / CBlibrary / c / msgtrans < prev    next >
Encoding:
Text File  |  2003-10-16  |  2.7 KB  |  79 lines

  1. /*
  2.  * CBLibrary - msgtrans
  3.  * Copyright (C) 2003  Chris Bazley
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Lesser General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2.1 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Lesser General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Lesser General Public
  16.  * License along with this library; if not, write to the Free Software
  17.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  */
  19.  
  20. /* Original version by Tony Houghton for !FormText */
  21.  
  22. #include "swis.h"
  23.  
  24. #include "err.h"
  25. #include "msgtrans.h"
  26.  
  27. static MessagesFD descriptor;
  28. static char messagebuffer[256] = ""; 
  29.  
  30. /* ----------------------------------------------------------------------- */
  31. /*                       Function prototypes                               */
  32.  
  33. static char *msgs_gen_lookup(const char *token, MessagesFD *file);
  34.  
  35. /* ----------------------------------------------------------------------- */
  36. /*                         Public functions                                */
  37.  
  38. MessagesFD *msgs_get_descriptor(void)
  39. {
  40.   return &descriptor;
  41. }
  42.  
  43. /* ----------------------------------------------------------------------- */
  44.  
  45. char *msgs_lookup(const char *token)
  46. {
  47.   /* look in application messages file */
  48.   return msgs_gen_lookup(token, &descriptor); 
  49. }
  50.  
  51. /* ----------------------------------------------------------------------- */
  52.  
  53. char *msgs_global(const char *token)
  54. {
  55.   /* look in global messages file */
  56.   return msgs_gen_lookup(token, 0); 
  57. }
  58.  
  59. /* ----------------------------------------------------------------------- */
  60.  
  61. char *msgs_lookupsub(const char *token, const char *subA, const char *subB, const char *subC, const char *subD)
  62. {
  63.   /* look in application messages file, with substitution */
  64.   messagebuffer[0] = '\0';
  65.   RE(_swix(MessageTrans_Lookup, _INR(0,7), &descriptor, token, messagebuffer, sizeof(messagebuffer), subA, subB, subC, subD));
  66.   return messagebuffer;
  67. }
  68.  
  69. /* ----------------------------------------------------------------------- */
  70. /*                         Private functions                               */
  71.  
  72. static char *msgs_gen_lookup(const char *token, MessagesFD *file)
  73. {
  74.   /* general veneer to MessageTrans_Lookup, placing string in our buffer */
  75.   messagebuffer[0] = '\0';
  76.   RE(_swix(MessageTrans_Lookup, _INR(0,3), file, token, messagebuffer, sizeof(messagebuffer)));
  77.   return messagebuffer;
  78. }
  79.